module.exports = async(etc, next) => {
    let userId = etc.session.userId
    let path = etc.path
    if (!userId) {
        if (path !== "/login") {
            etc.redirect('/login')
        } else {
            await next();
        }
    } else {
        if (path === "/") {
            await next();
        } else {
            etc.redirect("/")
        }
    }
}